#include <BaseObject.h>
#include <PhysicsObject.h>
#include <RenderObject.h>

void BaseObject::SetColor(float r, float g, float b, float a)
{
	gfx->SetColor(r,g,b,a);
}

void BaseObject::SetPosition(vec2 pos)
{	
	t.loc = pos;
	if( phys )
		phys->body->SetTransform( t.loc, -t.angle * Global::PI / 180.0f );
}

void BaseObject::SyncTransformToPhysics()
{
	t.loc = phys->body->GetTransform().p;
	t.SetRotateRadian( -phys->body->GetAngle() );
	velocity = phys->body->GetLinearVelocity();
}
		
void BaseObject::SetSleepState(truth canSleep)
{
	if( phys )
	{
		phys->body->SetSleepingAllowed(canSleep);
	}
}